#define _CRT_SECURE_NO_WARNINGS 1
#include "AVLTree.h"
#include <vector>

void TestAVL01() {
	int a[] = { 4, 2, 6, 1, 3, 5, 15, 7, 16, 14 };
	// {16, 3, 7, 11, 9, 26, 18, 14, 15}
	AVLTree<int, int> avtree;
	
	for (auto e : a) {
		if (e == 4) {
			int i = 0;
		}
		avtree.insert(make_pair(e, e));
	}
	avtree.InOrder();
	cout << avtree.height() << endl;
	cout << avtree.size() << endl;
	cout << avtree.IsBalance() << endl;
}

void TestAVL02() {
	const int N = 1000000;
	vector<int> v;
	v.reserve(N);
	srand(time(0));
	for (int i = 0; i < N; i++) {
		v.push_back(rand() + 1);
	}
	size_t begin1 = clock();
	AVLTree<int,int> tree;
	for (auto e : v)
		tree.insert({e, e});
	size_t end1 = clock();
	cout << "insert" << end1 - begin1 << endl;

	cout << "Height:" << tree.height() << endl;
	cout << "Size:" << tree.size() << endl;

	size_t begin2 = clock();
	for (auto e : v)
		tree.find(e);
	size_t end2 = clock();
	cout << "find:" << end2 - begin2 << endl;

	cout << tree.IsBalance() << endl;
}

int main() {
	TestAVL01();
	return 0;
}